package com.jiawei.链表.双链表;

import com.jiawei.链表.LinkedList;

import java.util.function.Consumer;

/**
 * @author : willian fu
 * @version : 1.0
 */
public class LinkedListBidirectional<E> implements LinkedList<E> {
    /**
     * 添加一个元素到链表尾节点
     *
     * @param val 待添加的值
     */
    @Override
    public void add(E val) {

    }

    /**
     * 添加一个元素到指定位置
     *
     * @param index 索引
     * @param val   值
     */
    @Override
    public void add(int index, E val) {

    }

    /**
     * 获取链表尾元素
     *
     * @return
     */
    @Override
    public E get() {
        return null;
    }

    /**
     * 获取头结点开始，指定位置元素
     *
     * @param index
     * @return
     */
    @Override
    public E get(int index) {
        return null;
    }

    /**
     * 返回链表长度
     *
     * @return
     */
    @Override
    public int size() {
        return 0;
    }

    /**
     * 删除链表尾元素
     */
    @Override
    public E remove() {
        return null;
    }

    /**
     * 删除从链表头开始指定位置元素
     *
     * @param index
     * @return
     */
    @Override
    public E remove(int index) {
        return null;
    }

    /**
     * 清空链表
     */
    @Override
    public void clear() {

    }

    @Override
    public void print() {

    }

    /**
     * Performs the given action for each element of the {@code Iterable}
     * until all elements have been processed or the action throws an
     * exception.  Unless otherwise specified by the implementing class,
     * actions are performed in the order of iteration (if an iteration order
     * is specified).  Exceptions thrown by the action are relayed to the
     * caller.
     *
     * @param action The action to be performed for each element
     * @throws NullPointerException if the specified action is null
     * @implSpec <p>The default implementation behaves as if:
     * <pre>{@code
     *     for (T t : this)
     *         action.accept(t);
     * }</pre>
     * @since 1.8
     */
    @Override
    public void forEach(Consumer<? super E> action) {

    }

    static class Node<E> implements LinkedList.Node<E>{

        //当前节点值
        E val;

        //前节点
        LinkedList.Node<E> before;

        //后节点
        LinkedList.Node<E> next;

        @Override
        public E getValue() {
            return null;
        }

        @Override
        public void addNext(LinkedList.Node<E> next) {

        }

        @Override
        public LinkedList.Node<E> next() {
            return null;
        }
    }
}
